/*
* Copyright (c) 2008-2011, Thomas Handorf, Nils Christian
* 
* This file is part of libScopes.
* libScopes is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* libScopes is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public License
* along with libScopes.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef th_netstruct_h
#define th_netstruct_h

#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include "array.h"

#ifdef SCOPES_USEBOOSTSERIALIZATION
#include <boost/serialization/version.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/nvp.hpp>
#endif // SCOPES_USEBOOSTSERIALIZATION

//using namespace _GLIBCXX_STD;

typedef std::vector<int>::size_type size_type; // this should also hold for other relevant elements types than int

typedef array<unsigned char> VC;
typedef array<size_type> VS;
typedef array<array<size_type>*> VVS;
typedef array<float> VF;
typedef array<array<float>*> VVF;

struct NetStruct {
	public:
//       friend class Net;
//       friend class RNet;
		NetStruct();//!<default constructor
		NetStruct(const NetStruct& ns2);//!<copy constructor.
		NetStruct(size_type nr, size_type nc);//!< constructor with allocate.
/*		NetStruct(string &str);
		NetStruct(string &str,size_type &pos);//!< constructor from string*/
		~NetStruct();//!<destructor
		void resize(size_type nr, size_type nc); //!<resize all vectors.
#ifdef SCOPES_USEBOOSTSERIALIZATION
      friend class boost::serialization::access;
		template<class Archive> void serialize(Archive & ar, const unsigned int version) {
		  ar & BOOST_SERIALIZATION_NVP(IN);
		  ar & BOOST_SERIALIZATION_NVP(OUT);
		  if (version>=2) ar & BOOST_SERIALIZATION_NVP(INH);
		  if (version>=2) ar & BOOST_SERIALIZATION_NVP(CMPI);
        if (version>=3) ar & BOOST_SERIALIZATION_NVP(CAT);
        if (version>=3) ar & BOOST_SERIALIZATION_NVP(PRP);
        if (version>=4) ar & BOOST_SERIALIZATION_NVP(FAM);
        if (version>=4) ar & BOOST_SERIALIZATION_NVP(FCN);
        if (version>=4) ar & BOOST_SERIALIZATION_NVP(hasFam);
        if (version>=5) ar & BOOST_SERIALIZATION_NVP(names);
        ar & BOOST_SERIALIZATION_NVP(INST);
		  ar & BOOST_SERIALIZATION_NVP(OUTST);
		  ar & BOOST_SERIALIZATION_NVP(CSUC);
		  ar & BOOST_SERIALIZATION_NVP(CPRE);
		  ar & BOOST_SERIALIZATION_NVP(REV);
		  ar & BOOST_SERIALIZATION_NVP(numR);
		  ar & BOOST_SERIALIZATION_NVP(numC);
		  ar & BOOST_SERIALIZATION_NVP(nextToAdd);
		  ar & BOOST_SERIALIZATION_NVP(refCount);
		}
#endif // SCOPES_USEBOOSTSERIALIZATION
		VVS* IN; //!<substrate indices for each rea
		VVS* OUT; //!<product indices for each rea
		VVS* INH; //!<inhibitor indices for each rea
		VVS* CMPI; //!<indices of substrates competively inhibited by a reaction
		VVS* CAT; //!<catalyst indices for each rea
		VVS* PRP; //!<propagators indices for each rea, products that propagate dpletion to inhibited substrates
		VVF* INST; //!<substrate stoichiometries in same order as IN
		VVF* OUTST; //!<product stoichiometries in same order as IN
		VVS* CSUC; //!<successor reactions for each compound
		VVS* CPRE; //!<predecessor reactions for each compound
		VVS* FAM; //!<family members for compound/protein families
		VVS* FCN; //! family channels (could be uniprot ids a protein family stands for, but only size_type numbers). Non families should be assigned a cheannel, too, if they are part of a family
		VC* REV; //!< reversibility for each reaction
		size_type numR; //!<number of reactions
		size_type numC; //!<number of compounds
		size_type nextToAdd; //!<index of reaction added last + 1
		size_type refCount; //!< how many Net-objects use this struct
		bool hasFam;
      array<std::string>* names;
//      string* toString();//!< copy network data into a string
//		void appendToString(string &str);//!< append network data to a string
	private:
//		void initFromString(string &str,size_type &pos);//!< construct from string
	
};
#ifdef SCOPES_USEBOOSTSERIALIZATION
BOOST_CLASS_VERSION(NetStruct, 5)
#endif // SCOPES_USEBOOSTSERIALIZATION

#endif
